/**
 * <copyright>
 * Copyrigth 2007 Aurelien Moreau
 *
 * This file is part of ProcessShop.
 *
 * ProcessShop is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * ProcessShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with ProcessShop; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * </copyright>
 *
 * $Id$
 */
package net.yienyien.process.bpd.util;

import java.util.List;

import net.yienyien.process.bpd.*;
import net.yienyien.process.bpd.BPDComponent;
import net.yienyien.process.bpd.BPDElement;
import net.yienyien.process.bpd.BPDModel;
import net.yienyien.process.bpd.BPDObject;
import net.yienyien.process.bpd.BpdPackage;
import net.yienyien.process.bpd.ControlFlowRelation;
import net.yienyien.process.bpd.DataBasedXOR;
import net.yienyien.process.bpd.EndEvent;
import net.yienyien.process.bpd.Event;
import net.yienyien.process.bpd.EventBasedXOR;
import net.yienyien.process.bpd.Gateway;
import net.yienyien.process.bpd.IntermediateEvent;
import net.yienyien.process.bpd.ParallelFork;
import net.yienyien.process.bpd.ParallelJoin;
import net.yienyien.process.bpd.StartEvent;
import net.yienyien.process.bpd.Task;
import net.yienyien.process.bpd.XORMerge;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;

/**
 * <!-- begin-user-doc -->
 * The <b>Switch</b> for the model's inheritance hierarchy.
 * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
 * to invoke the <code>caseXXX</code> method for each class of the model,
 * starting with the actual class of the object
 * and proceeding up the inheritance hierarchy
 * until a non-null result is returned,
 * which is the result of the switch.
 * <!-- end-user-doc -->
 * @see net.yienyien.process.bpd.BpdPackage
 * @generated
 */
public class BpdSwitch<T> {
	/**
	 * The cached model package
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static BpdPackage modelPackage;

	/**
	 * Creates an instance of the switch.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BpdSwitch() {
		if (modelPackage == null) {
			modelPackage = BpdPackage.eINSTANCE;
		}
	}

	/**
	 * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
	 * @generated
	 */
	public T doSwitch(EObject theEObject) {
		return doSwitch(theEObject.eClass(), theEObject);
	}

	/**
	 * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
	 * @generated
	 */
	protected T doSwitch(EClass theEClass, EObject theEObject) {
		if (theEClass.eContainer() == modelPackage) {
			return doSwitch(theEClass.getClassifierID(), theEObject);
		}
		else {
			List<EClass> eSuperTypes = theEClass.getESuperTypes();
			return
				eSuperTypes.isEmpty() ?
					defaultCase(theEObject) :
					doSwitch(eSuperTypes.get(0), theEObject);
		}
	}

	/**
	 * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
	 * @generated
	 */
	protected T doSwitch(int classifierID, EObject theEObject) {
		switch (classifierID) {
			case BpdPackage.BPD_OBJECT: {
				BPDObject bpdObject = (BPDObject)theEObject;
				T result = caseBPDObject(bpdObject);
				if (result == null) result = caseBPDElement(bpdObject);
				if (result == null) result = caseEModelElement(bpdObject);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.TASK: {
				Task task = (Task)theEObject;
				T result = caseTask(task);
				if (result == null) result = caseBPDObject(task);
				if (result == null) result = caseBPDElement(task);
				if (result == null) result = caseEModelElement(task);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.EVENT: {
				Event event = (Event)theEObject;
				T result = caseEvent(event);
				if (result == null) result = caseBPDObject(event);
				if (result == null) result = caseBPDElement(event);
				if (result == null) result = caseEModelElement(event);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.GATEWAY: {
				Gateway gateway = (Gateway)theEObject;
				T result = caseGateway(gateway);
				if (result == null) result = caseBPDObject(gateway);
				if (result == null) result = caseBPDElement(gateway);
				if (result == null) result = caseEModelElement(gateway);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.START_EVENT: {
				StartEvent startEvent = (StartEvent)theEObject;
				T result = caseStartEvent(startEvent);
				if (result == null) result = caseEvent(startEvent);
				if (result == null) result = caseBPDObject(startEvent);
				if (result == null) result = caseBPDElement(startEvent);
				if (result == null) result = caseEModelElement(startEvent);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.INTERMEDIATE_EVENT: {
				IntermediateEvent intermediateEvent = (IntermediateEvent)theEObject;
				T result = caseIntermediateEvent(intermediateEvent);
				if (result == null) result = caseEvent(intermediateEvent);
				if (result == null) result = caseBPDObject(intermediateEvent);
				if (result == null) result = caseBPDElement(intermediateEvent);
				if (result == null) result = caseEModelElement(intermediateEvent);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.END_EVENT: {
				EndEvent endEvent = (EndEvent)theEObject;
				T result = caseEndEvent(endEvent);
				if (result == null) result = caseEvent(endEvent);
				if (result == null) result = caseBPDObject(endEvent);
				if (result == null) result = caseBPDElement(endEvent);
				if (result == null) result = caseEModelElement(endEvent);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.PARALLEL_FORK: {
				ParallelFork parallelFork = (ParallelFork)theEObject;
				T result = caseParallelFork(parallelFork);
				if (result == null) result = caseGateway(parallelFork);
				if (result == null) result = caseBPDObject(parallelFork);
				if (result == null) result = caseBPDElement(parallelFork);
				if (result == null) result = caseEModelElement(parallelFork);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.PARALLEL_JOIN: {
				ParallelJoin parallelJoin = (ParallelJoin)theEObject;
				T result = caseParallelJoin(parallelJoin);
				if (result == null) result = caseGateway(parallelJoin);
				if (result == null) result = caseBPDObject(parallelJoin);
				if (result == null) result = caseBPDElement(parallelJoin);
				if (result == null) result = caseEModelElement(parallelJoin);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.DATA_BASED_XOR: {
				DataBasedXOR dataBasedXOR = (DataBasedXOR)theEObject;
				T result = caseDataBasedXOR(dataBasedXOR);
				if (result == null) result = caseGateway(dataBasedXOR);
				if (result == null) result = caseBPDObject(dataBasedXOR);
				if (result == null) result = caseBPDElement(dataBasedXOR);
				if (result == null) result = caseEModelElement(dataBasedXOR);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.EVENT_BASED_XOR: {
				EventBasedXOR eventBasedXOR = (EventBasedXOR)theEObject;
				T result = caseEventBasedXOR(eventBasedXOR);
				if (result == null) result = caseGateway(eventBasedXOR);
				if (result == null) result = caseBPDObject(eventBasedXOR);
				if (result == null) result = caseBPDElement(eventBasedXOR);
				if (result == null) result = caseEModelElement(eventBasedXOR);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.XOR_MERGE: {
				XORMerge xorMerge = (XORMerge)theEObject;
				T result = caseXORMerge(xorMerge);
				if (result == null) result = caseGateway(xorMerge);
				if (result == null) result = caseBPDObject(xorMerge);
				if (result == null) result = caseBPDElement(xorMerge);
				if (result == null) result = caseEModelElement(xorMerge);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.CONTROL_FLOW_RELATION: {
				ControlFlowRelation controlFlowRelation = (ControlFlowRelation)theEObject;
				T result = caseControlFlowRelation(controlFlowRelation);
				if (result == null) result = caseBPDElement(controlFlowRelation);
				if (result == null) result = caseEModelElement(controlFlowRelation);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.BPD_MODEL: {
				BPDModel bpdModel = (BPDModel)theEObject;
				T result = caseBPDModel(bpdModel);
				if (result == null) result = caseBPDElement(bpdModel);
				if (result == null) result = caseEModelElement(bpdModel);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.BPD_ELEMENT: {
				BPDElement bpdElement = (BPDElement)theEObject;
				T result = caseBPDElement(bpdElement);
				if (result == null) result = caseEModelElement(bpdElement);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case BpdPackage.BPD_COMPONENT: {
				BPDComponent bpdComponent = (BPDComponent)theEObject;
				T result = caseBPDComponent(bpdComponent);
				if (result == null) result = caseTask(bpdComponent);
				if (result == null) result = caseBPDObject(bpdComponent);
				if (result == null) result = caseBPDElement(bpdComponent);
				if (result == null) result = caseEModelElement(bpdComponent);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			default: return defaultCase(theEObject);
		}
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>BPD Object</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>BPD Object</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseBPDObject(BPDObject object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Task</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Task</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseTask(Task object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Event</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Event</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseEvent(Event object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Gateway</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Gateway</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseGateway(Gateway object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Start Event</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Start Event</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseStartEvent(StartEvent object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Intermediate Event</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Intermediate Event</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseIntermediateEvent(IntermediateEvent object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>End Event</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>End Event</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseEndEvent(EndEvent object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Parallel Fork</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Parallel Fork</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseParallelFork(ParallelFork object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Parallel Join</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Parallel Join</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseParallelJoin(ParallelJoin object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Data Based XOR</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Data Based XOR</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseDataBasedXOR(DataBasedXOR object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Event Based XOR</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Event Based XOR</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseEventBasedXOR(EventBasedXOR object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XOR Merge</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XOR Merge</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXORMerge(XORMerge object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Control Flow Relation</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Control Flow Relation</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseControlFlowRelation(ControlFlowRelation object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>BPD Model</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>BPD Model</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseBPDModel(BPDModel object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>BPD Element</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>BPD Element</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseBPDElement(BPDElement object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>BPD Component</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>BPD Component</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseBPDComponent(BPDComponent object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>EModel Element</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>EModel Element</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseEModelElement(EModelElement object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch, but this is the last case anyway.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject)
	 * @generated
	 */
	public T defaultCase(EObject object) {
		return null;
	}

} //BpdSwitch
